class Solution {
public:
    int lengthOfLIS(vector<int>& nums) {
        int n=nums.size();
        vector<int> rem(n+1,1);
        int res_max=1;
        for(int i=1;i<n;i++){
            int maxn=INT_MIN;
            for(int j=0;j<i;j++){
                if(nums[j]<nums[i]){
                    maxn=max(maxn,rem[j]+1);
                    //cout<<"i="<<i<<",rem[j]+1="<<rem[j]+1<<endl;
                }
            }
            //cout<<"i="<<i<<",maxn="<<maxn<<endl;
            rem[i]=maxn==INT_MIN?1:maxn;
            if(rem[i]>res_max)
                res_max=rem[i];
        }
        return res_max;
    }
};
